<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PaginatedList<BizWeb.Models.Site_Post>>" %>
<%@ Import Namespace="BizWeb.Core.Helpers"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Posts
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Posts</h2>

    <% if (User.Identity.IsAuthenticated) { %>
    <p>
        <%= Html.ActionLink("Create New", "Create") %>
    </p>
    <% } %>


    <% foreach (var item in Model) { %>
    
        <% if (User.Identity.IsAuthenticated)
           { %>    
            <%= Html.ActionLink("Edit", "Edit", new { id = item.PostID })%> |
            <%= Html.ActionLink("Delete", "Delete", new { id = item.PostID })%><br />
        <% } %>

        <%=Html.ActionLink(item.Title,"Details", new{year = item.DatePublished.Value.Year, month = item.DatePublished.Value.Month, 
                day = item.DatePublished.Value.Day, slug = item.Slug}) %><br />
        <%=Html.Encode(item.DatePublished) %><br />
        <%=Html.TextAbstract(item.PlainContent, 50) %>
        <br /><br />    
    <% } %>

    <% if (Model.HasPreviousPage)
     {%>
            <%=Html.RouteLink("Previous Page", "PostPaging", new { page = (Model.PageIndex - 1) })%>
        <%
     }%>

    <% if (Model.HasNextPage)
     {%>
            <%=Html.RouteLink("Next Page", "PostPaging", new { page = (Model.PageIndex + 1) })%>
        <%
     }%>

</asp:Content>